/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * frmDiaOc.java
 *
 * Created on May 14, 2011, 1:38:09 PM
 */

package Presentation;

import RSCall.DiaOcRSc;
import RSCall.DuongRSc;
import RSCall.HinhAnhRSc;
import RSCall.KhachHangRSc;
import RSCall.LoaiDiaOCRSc;
import RSCall.NoiDungRSc;
import RSCall.PhieuDangKyRSc;
import RSCall.PhuongRSc;
import RSCall.QCBangRSc;
import RSCall.QCBaoRSc;
import RSCall.QuanRSc;
import RSCall.ThanhPhoRSc;
import RSCall.ToBuomRSc;
import Entities.DIAOC;
import Entities.DUONG;
import Entities.KHACHHANG;
import Entities.LOAIDIAOC;
import Entities.PHIEUDANGKY;
import Entities.PHUONG;
import Entities.QUAN;
import Entities.THANHPHO;
import java.awt.Font;
import java.sql.Date;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author VooKa
 */
public class frmDiaOc extends javax.swing.JInternalFrame {

    /** Creates new form frmDiaOc */
    public frmDiaOc() {
        initComponents();
        Creation();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jPanel1 = new javax.swing.JPanel();
        jLabel7 = new javax.swing.JLabel();
        jlabel = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        btnAdd = new javax.swing.JButton();
        btnUpdate = new javax.swing.JButton();
        btnDelete = new javax.swing.JButton();
        cbxTrangThai = new javax.swing.JComboBox();
        jLabel8 = new javax.swing.JLabel();
        tbxGiaBan = new javax.swing.JTextField();
        cbxLoaiDiaOc = new javax.swing.JComboBox();
        tbxDienTichDat = new javax.swing.JTextField();
        tbxDienTichXayDung = new javax.swing.JTextField();
        tbxHuong = new javax.swing.JTextField();
        tbxViTri = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        txtAreaMoTa = new javax.swing.JTextArea();
        jLabel12 = new javax.swing.JLabel();
        cbxPhuong = new javax.swing.JComboBox();
        jLabel13 = new javax.swing.JLabel();
        cbxDuong = new javax.swing.JComboBox();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        cbxThanhPho = new javax.swing.JComboBox();
        tbxDiaChiCTDiaOc = new javax.swing.JTextField();
        cbxQuan = new javax.swing.JComboBox();
        jLabel16 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        tbxMaDiaOc_TraCuu = new javax.swing.JTextField();
        cbxLoaiDiaOcTraCuu = new javax.swing.JComboBox();
        btnTimKiem = new javax.swing.JButton();
        cbxTrangThaiTraCuu = new javax.swing.JComboBox();
        chbxMaDiaOc = new javax.swing.JCheckBox();
        chbxLoaiDiaOc = new javax.swing.JCheckBox();
        chbxTrangThai = new javax.swing.JCheckBox();
        btnDanhSach = new javax.swing.JButton();
        btnNoiDungQC = new javax.swing.JButton();
        btnPhieuDangKy = new javax.swing.JButton();
        btnDeleteAll = new javax.swing.JButton();
        btnHetHan = new javax.swing.JButton();
        btnGiaHan = new javax.swing.JButton();
        cbxThanhPhoTraCuu = new javax.swing.JComboBox();
        chbxThanhPho = new javax.swing.JCheckBox();
        cbxQuanTraCuu = new javax.swing.JComboBox();
        chbxQuan = new javax.swing.JCheckBox();
        cbxPhuongTraCuu = new javax.swing.JComboBox();
        chbxPhuong = new javax.swing.JCheckBox();
        cbxDuongTraCuu = new javax.swing.JComboBox();
        chbxDuong = new javax.swing.JCheckBox();
        btnThongBao = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        tblDiaOc = new javax.swing.JTable();

        setBorder(new javax.swing.border.LineBorder(new java.awt.Color(153, 153, 153), 2, true));
        setClosable(true);
        setTitle(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("titlefrmDiaOc"));
        setDebugGraphicsOptions(javax.swing.DebugGraphics.NONE_OPTION);
        setPreferredSize(new java.awt.Dimension(1000, 580));
        addInternalFrameListener(new javax.swing.event.InternalFrameListener() {
            public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameClosing(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameIconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameOpened(javax.swing.event.InternalFrameEvent evt) {
                formInternalFrameOpened(evt);
            }
        });

        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel7.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("state"));

        jlabel.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("describe"));

        jLabel6.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("location"));

        jLabel1.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("property type"));

        jLabel5.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("direction"));

        jLabel3.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("s1"));

        jLabel2.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("address"));

        jLabel4.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("s2"));

        btnAdd.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("insert"));
        btnAdd.setEnabled(false);
        btnAdd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAddActionPerformed(evt);
            }
        });

        btnUpdate.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("update"));
        btnUpdate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnUpdateActionPerformed(evt);
            }
        });

        btnDelete.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("delete"));
        btnDelete.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDeleteActionPerformed(evt);
            }
        });

        cbxTrangThai.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Chưa bán", "Đã bán" }));

        jLabel8.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("cost"));

        tbxGiaBan.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                tbxGiaBanKeyTyped(evt);
            }
        });

        cbxLoaiDiaOc.setAutoscrolls(true);

        tbxDienTichDat.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                tbxDienTichDatKeyTyped(evt);
            }
        });

        tbxDienTichXayDung.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                tbxDienTichXayDungKeyTyped(evt);
            }
        });

        txtAreaMoTa.setColumns(20);
        txtAreaMoTa.setLineWrap(true);
        txtAreaMoTa.setRows(5);
        txtAreaMoTa.setWrapStyleWord(true);
        txtAreaMoTa.setAutoscrolls(false);
        jScrollPane1.setViewportView(txtAreaMoTa);

        jLabel12.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("precinct"));

        jLabel13.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("street"));

        jLabel14.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("detail"));

        jLabel15.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("city"));

        cbxQuan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbxQuanActionPerformed(evt);
            }
        });

        jLabel16.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("district"));

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jlabel)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 249, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(45, 45, 45)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel8)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(tbxGiaBan, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(btnUpdate))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(btnAdd, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(btnDelete, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel1)
                                .addGap(18, 18, 18)
                                .addComponent(cbxLoaiDiaOc, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel3)
                                    .addComponent(jLabel4)
                                    .addComponent(jLabel6)
                                    .addComponent(jLabel7)
                                    .addComponent(jLabel5))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(tbxHuong)
                                    .addComponent(cbxTrangThai, 0, 107, Short.MAX_VALUE)
                                    .addComponent(tbxViTri)
                                    .addComponent(tbxDienTichDat)
                                    .addComponent(tbxDienTichXayDung))))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel2)
                            .addComponent(jLabel12)
                            .addComponent(jLabel13)
                            .addComponent(jLabel14)
                            .addComponent(jLabel16)
                            .addComponent(jLabel15))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(cbxDuong, javax.swing.GroupLayout.Alignment.TRAILING, 0, 151, Short.MAX_VALUE)
                            .addComponent(cbxPhuong, javax.swing.GroupLayout.Alignment.TRAILING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(cbxQuan, javax.swing.GroupLayout.Alignment.TRAILING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(cbxThanhPho, javax.swing.GroupLayout.Alignment.TRAILING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(tbxDiaChiCTDiaOc))))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(cbxLoaiDiaOc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addGap(11, 11, 11)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel3)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(tbxDienTichDat, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel15)
                        .addComponent(cbxThanhPho, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(11, 11, 11)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(tbxDienTichXayDung, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel16)
                    .addComponent(cbxQuan, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel6)
                            .addComponent(tbxViTri, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel7)
                            .addComponent(cbxTrangThai, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel13)
                            .addComponent(cbxDuong, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(tbxHuong, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel14)
                            .addComponent(tbxDiaChiCTDiaOc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel12)
                        .addComponent(cbxPhuong, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(14, 14, 14)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jlabel)
                    .addComponent(jLabel8))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(12, 12, 12)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(btnAdd, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(tbxGiaBan, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(btnUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnDelete, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        tbxMaDiaOc_TraCuu.setEnabled(false);

        cbxLoaiDiaOcTraCuu.setEnabled(false);

        btnTimKiem.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("search"));
        btnTimKiem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTimKiemActionPerformed(evt);
            }
        });

        cbxTrangThaiTraCuu.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Chưa bán", "Đã bán" }));
        cbxTrangThaiTraCuu.setEnabled(false);

        chbxMaDiaOc.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("propertyid"));
        chbxMaDiaOc.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chbxMaDiaOcActionPerformed(evt);
            }
        });

        chbxLoaiDiaOc.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("property type"));
        chbxLoaiDiaOc.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chbxLoaiDiaOcActionPerformed(evt);
            }
        });

        chbxTrangThai.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("state"));
        chbxTrangThai.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chbxTrangThaiActionPerformed(evt);
            }
        });

        btnDanhSach.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("list"));
        btnDanhSach.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDanhSachActionPerformed(evt);
            }
        });

        btnNoiDungQC.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("adcontent"));
        btnNoiDungQC.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNoiDungQCActionPerformed(evt);
            }
        });

        btnPhieuDangKy.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("signinform"));
        btnPhieuDangKy.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPhieuDangKyActionPerformed(evt);
            }
        });

        btnDeleteAll.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("deleteall"));
        btnDeleteAll.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDeleteAllActionPerformed(evt);
            }
        });

        btnHetHan.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("outofdate"));
        btnHetHan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnHetHanActionPerformed(evt);
            }
        });

        btnGiaHan.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("extend"));
        btnGiaHan.setEnabled(false);
        btnGiaHan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnGiaHanActionPerformed(evt);
            }
        });

        cbxThanhPhoTraCuu.setEnabled(false);

        chbxThanhPho.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("city"));
        chbxThanhPho.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chbxThanhPhoActionPerformed(evt);
            }
        });

        cbxQuanTraCuu.setEnabled(false);

        chbxQuan.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("district"));
        chbxQuan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chbxQuanActionPerformed(evt);
            }
        });

        cbxPhuongTraCuu.setEnabled(false);

        chbxPhuong.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("precinct"));
        chbxPhuong.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chbxPhuongActionPerformed(evt);
            }
        });

        cbxDuongTraCuu.setEnabled(false);

        chbxDuong.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("street"));
        chbxDuong.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chbxDuongActionPerformed(evt);
            }
        });

        btnThongBao.setText(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("warntocustomer"));
        btnThongBao.setEnabled(false);
        btnThongBao.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnThongBaoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(btnThongBao)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnGiaHan))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(chbxThanhPho)
                            .addComponent(chbxQuan)
                            .addComponent(chbxPhuong)
                            .addComponent(chbxDuong)
                            .addComponent(chbxTrangThai)
                            .addComponent(chbxMaDiaOc)
                            .addComponent(chbxLoaiDiaOc))
                        .addGap(18, 18, Short.MAX_VALUE)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(cbxLoaiDiaOcTraCuu, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(tbxMaDiaOc_TraCuu)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(cbxTrangThaiTraCuu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(0, 0, Short.MAX_VALUE))
                            .addComponent(cbxDuongTraCuu, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(cbxPhuongTraCuu, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(cbxQuanTraCuu, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(cbxThanhPhoTraCuu, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(btnDeleteAll, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 119, Short.MAX_VALUE)
                    .addComponent(btnPhieuDangKy, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnNoiDungQC, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnTimKiem, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnDanhSach, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnHetHan, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(chbxMaDiaOc)
                    .addComponent(tbxMaDiaOc_TraCuu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnDanhSach))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(chbxThanhPho)
                    .addComponent(cbxThanhPhoTraCuu, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnTimKiem))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(chbxQuan)
                    .addComponent(cbxQuanTraCuu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnNoiDungQC))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(chbxPhuong)
                    .addComponent(cbxPhuongTraCuu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnPhieuDangKy))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cbxDuongTraCuu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnDeleteAll)
                    .addComponent(chbxDuong))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(chbxLoaiDiaOc)
                    .addComponent(cbxLoaiDiaOcTraCuu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnHetHan))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(chbxTrangThai)
                    .addComponent(cbxTrangThaiTraCuu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnGiaHan)
                    .addComponent(btnThongBao))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        tblDiaOc.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tblDiaOc.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tblDiaOcMouseClicked(evt);
            }
        });
        jScrollPane2.setViewportView(tblDiaOc);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 976, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 165, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void formInternalFrameOpened(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameOpened
        try {
            dbDiaOc = new DiaOcRSc();
            this.LoadData(dbDiaOc.mainList);
        } catch (Exception ex) {
            Logger.getLogger(frmDiaOc.class.getName()).log(Level.SEVERE, null, ex);
        }
       
        
    }//GEN-LAST:event_formInternalFrameOpened

    // Xử lý chọn Địa ốc từ danh sách
    private void tblDiaOcMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblDiaOcMouseClicked
         int index = this.tblDiaOc.getSelectedRow();
        String maDiaOc = this.tblDiaOc.getValueAt(index, 0).toString();
        DIAOC d = new DIAOC();
        try{
            d = dbDiaOc.GetRowByID(maDiaOc);
            cbxLoaiDiaOc.setSelectedIndex(listLoaiDiaOc.indexOf(d.getMaLoaiDiaOc()));
            cbxThanhPho.setSelectedIndex(listThanhPho.indexOf(d.getDiaChiDiaOc().getMaThanhPho()));
            cbxQuan.setSelectedIndex(listQuan.indexOf(d.getDiaChiDiaOc().getMaQuan()));
            cbxPhuong.setSelectedIndex(listPhuong.indexOf(d.getDiaChiDiaOc().getMaPhuong())) ;
            cbxDuong.setSelectedIndex(listDuong.indexOf(d.getDiaChiDiaOc().getMaDuong()));
            tbxDiaChiCTDiaOc.setText(d.getDiaChiDiaOc().getDiaChiCT().trim());
            tbxDienTichDat.setText(d.getDienTichDat().toString().trim());
            tbxDienTichXayDung.setText(d.getDienTichXayDung().toString().trim());
            tbxHuong.setText(d.getHuong().trim());
            tbxViTri.setText(d.getViTri().trim());
            if (d.getTrangThai().equals(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("notsell"))) {
                cbxTrangThai.setSelectedIndex(0);
            }else cbxTrangThai.setSelectedIndex(1);
            txtAreaMoTa.setText(d.getMoTa().trim());
            tbxGiaBan.setText(d.getGiaBan().toString());
            
        }catch(Exception ev){
            JOptionPane.showMessageDialog(rootPane, ev.toString());
        }
    }//GEN-LAST:event_tblDiaOcMouseClicked

    // Xử lý thêm mới Địa ốc
    private void btnAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddActionPerformed
        btnGiaHan.setEnabled(false);
        btnThongBao.setEnabled(false);
        String maLoaiDiaOc = ((LOAIDIAOC)cbxLoaiDiaOc.getSelectedItem()).getMaLoaiDiaOc();
        String maThanhPho = ((THANHPHO)cbxThanhPho.getSelectedItem()).getMaThanhPho();
        String maQuan = ((QUAN)cbxQuan.getSelectedItem()).getMaQuan();
        String maPhuong = ((PHUONG)cbxPhuong.getSelectedItem()).getMaPhuong();
        String maDuong = ((DUONG)cbxDuong.getSelectedItem()).getMaDuong();
        
        String diaChiCT = tbxDiaChiCTDiaOc.getText().trim();
        
        String dienTichDat = tbxDienTichDat.getText().trim();
        String dienTichXD = tbxDienTichXayDung.getText().trim();
        String huong = tbxHuong.getText().trim();
        String viTri = tbxViTri.getText().trim();
        String moTa = txtAreaMoTa.getText().trim();
        String trangThai = cbxTrangThai.getSelectedItem().toString();
        String giaBan = tbxGiaBan.getText().trim();
        if(dienTichDat.isEmpty()){
            JOptionPane.showMessageDialog(this, java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("notenters1property"));
        }else if(dienTichXD.isEmpty()){
            JOptionPane.showMessageDialog(this, java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("notenters2property"));
        }else if(huong.isEmpty()){
            JOptionPane.showMessageDialog(this, java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("notenterdirectionproperty"));
        }else if(viTri.isEmpty()){
            JOptionPane.showMessageDialog(this, java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("notenterlocationproperty"));
        }else if(trangThai.isEmpty()){
            JOptionPane.showMessageDialog(this, java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("notselectstate"));
        }else if(moTa.isEmpty()){
            JOptionPane.showConfirmDialog(this, java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("notenterdescribeproperty"));
        }else if(giaBan.isEmpty()){
            JOptionPane.showConfirmDialog(this, java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("notentercostproperty"));
        }else {
            try{
                Float dtDat = Float.MIN_VALUE;
                Float dtXD = Float.MIN_VALUE;
                Float giaBanDiaOc = Float.MIN_VALUE;
                try{
                    dtDat = Float.parseFloat(dienTichDat);
                    dtXD = Float.parseFloat(dienTichXD);
                    giaBanDiaOc = Float.parseFloat(giaBan);
                    dbDiaOc.Insert(maLoaiDiaOc, maThanhPho, maQuan, maPhuong,
                            maDuong, diaChiCT, dtDat, dtXD, huong, viTri,
                            moTa, trangThai, giaBanDiaOc);
                    
                    this.LoadData(dbDiaOc.GetAllRows());
                    JOptionPane.showMessageDialog(this, java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("insertedaproperty"));
                }catch(NumberFormatException e){
                    JOptionPane.showMessageDialog(this, java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("validnumber"));
                }
            }catch(Exception e){
                JOptionPane.showMessageDialog(this, e.toString());
            }
        }
    }//GEN-LAST:event_btnAddActionPerformed

    // Sửa Địa ốc
    private void btnUpdateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnUpdateActionPerformed
        btnGiaHan.setEnabled(false);
        btnThongBao.setEnabled(false);
        String maLoaiDiaOc = ((LOAIDIAOC)cbxLoaiDiaOc.getSelectedItem()).getMaLoaiDiaOc();
        String maThanhPho = ((THANHPHO)cbxThanhPho.getSelectedItem()).getMaThanhPho();
        String maQuan = ((QUAN)cbxQuan.getSelectedItem()).getMaQuan();
        String maPhuong = ((PHUONG)cbxPhuong.getSelectedItem()).getMaPhuong();
        String maDuong = ((DUONG)cbxDuong.getSelectedItem()).getMaDuong();
        
        String diaChiCT = tbxDiaChiCTDiaOc.getText().trim();
        String dienTichDat = tbxDienTichDat.getText().trim();
        String dienTichXD = tbxDienTichXayDung.getText().trim();
        String huong = tbxHuong.getText().trim();
        String viTri = tbxViTri.getText().trim();
        String moTa = txtAreaMoTa.getText().trim();
        String giaBan = tbxGiaBan.getText().trim();
        if(this.tblDiaOc.getSelectedRow()==-1){
            JOptionPane.showMessageDialog(this, java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("mustselectaproperty"));
        }else if(dienTichDat.isEmpty()){
            JOptionPane.showMessageDialog(this, java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("notenters1property"));
        }else if(dienTichXD.isEmpty()){
            JOptionPane.showMessageDialog(this, java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("notenters2property"));
        }else if(huong.isEmpty()){
            JOptionPane.showMessageDialog(this, java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("notenterdirectionproperty"));
        }else if(viTri.isEmpty()){
            JOptionPane.showMessageDialog(this, java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("notenterlocationproperty"));
        }else if(moTa.isEmpty()){
            JOptionPane.showConfirmDialog(this, java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("notenterdescribeproperty"));
        }else if(giaBan.isEmpty()){
            JOptionPane.showConfirmDialog(this, java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("notentercostproperty"));
        }else{
            try{
                String maDiaOc = this.tblDiaOc.getValueAt(this.tblDiaOc.getSelectedRow(), 0).toString();
                Float dtDat = Float.MIN_VALUE;
                Float dtXD = Float.MIN_VALUE;
                String trangThai = cbxTrangThai.getSelectedItem().toString();
                Float giaBanDiaOc = Float.MIN_VALUE;
                
                try{
                    dtDat = Float.parseFloat(dienTichDat);
                    dtXD = Float.parseFloat(dienTichXD);
                    giaBanDiaOc = Float.parseFloat(giaBan);
                    dbDiaOc.Update(maDiaOc, maLoaiDiaOc, maThanhPho, maQuan,
                            maPhuong, maDuong, diaChiCT, dtDat, dtXD, huong,
                            viTri, moTa, trangThai, giaBanDiaOc);
                    
                    this.LoadData(dbDiaOc.GetAllRows());
                    JOptionPane.showMessageDialog(this, java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("updatedaproperty"));
                }catch(NumberFormatException e){
                    JOptionPane.showMessageDialog(this, java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("validnumber"));
                }
            }catch(Exception e){
                JOptionPane.showMessageDialog(this, e.toString());
            }
        }
    }//GEN-LAST:event_btnUpdateActionPerformed

    // Xử lý xóa Địa ốc
    private void btnDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeleteActionPerformed
        btnGiaHan.setEnabled(false);
        btnThongBao.setEnabled(false);
        if(this.tblDiaOc.getSelectedRow()==-1)
            JOptionPane.showMessageDialog(this, java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("mustselectaproperty"));
        else
        {
            int i = JOptionPane.showConfirmDialog(this, java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("really delete"),
                    java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("warn"),JOptionPane.YES_NO_OPTION);
            if(i == 0)
            {
                try
                {
                    dbDiaOc.Delete((String)this.tblDiaOc.getValueAt(this.tblDiaOc.getSelectedRow(),0));
                    this.LoadData(dbDiaOc.GetAllRows());
                }catch(Exception e)
                {
                    JOptionPane.showMessageDialog(this, e.toString());
                }
            }
        }
    }//GEN-LAST:event_btnDeleteActionPerformed

    // Show toàn bộ danh sách
    private void btnDanhSachActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDanhSachActionPerformed
        btnGiaHan.setEnabled(false);
        btnThongBao.setEnabled(false);
        try {
            dbDiaOc = new DiaOcRSc();
            this.LoadData(dbDiaOc.mainList);
        } catch (Exception ex) {
            Logger.getLogger(frmDiaOc.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_btnDanhSachActionPerformed

    private void chbxMaDiaOcActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chbxMaDiaOcActionPerformed
        tbxMaDiaOc_TraCuu.setEnabled(chbxMaDiaOc.isSelected());
        chbxThanhPho.setEnabled(!chbxMaDiaOc.isSelected());
        chbxQuan.setEnabled(!chbxMaDiaOc.isSelected());
        chbxPhuong.setEnabled(!chbxMaDiaOc.isSelected());
        chbxDuong.setEnabled(!chbxMaDiaOc.isSelected());
        chbxLoaiDiaOc.setEnabled(!chbxMaDiaOc.isSelected());
        chbxTrangThai.setEnabled(!chbxMaDiaOc.isSelected());
        
    }//GEN-LAST:event_chbxMaDiaOcActionPerformed

    private void chbxLoaiDiaOcActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chbxLoaiDiaOcActionPerformed
        cbxLoaiDiaOcTraCuu.setEnabled(chbxLoaiDiaOc.isSelected());
    }//GEN-LAST:event_chbxLoaiDiaOcActionPerformed

    private void chbxTrangThaiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chbxTrangThaiActionPerformed
        cbxTrangThaiTraCuu.setEnabled(chbxTrangThai.isSelected());
    }//GEN-LAST:event_chbxTrangThaiActionPerformed

    // Xử lý tìm kiếm
    private void btnTimKiemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTimKiemActionPerformed
        btnGiaHan.setEnabled(false);
        btnThongBao.setEnabled(false);
        try {
            ArrayList<DIAOC> rs = new ArrayList<DIAOC>();                           // List DIAOC kết quả tìm kiếm
            ArrayList<DIAOC> rsTemp = new ArrayList<DIAOC>();
            rs = dbDiaOc.GetAllRows();
            
            if(chbxMaDiaOc.isSelected()){                                               // Tìm kiếm theo Mã địa ốc
                rsTemp = (ArrayList<DIAOC>)rs.clone();
                rs.clear();
                if (tbxMaDiaOc_TraCuu.getText().trim().isEmpty()) {
                    JOptionPane.showMessageDialog(this, java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("mustenterpropertyid"));
                }else if(tbxMaDiaOc_TraCuu.getText().trim().length() != 5){
                    JOptionPane.showMessageDialog(this, java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("validMaDiaOc"));
                }else{
                    for(DIAOC d : rsTemp){
                        if (d.getMaDiaOc().equalsIgnoreCase(tbxMaDiaOc_TraCuu.getText().trim())) {
                            rs.add(d);
                            break;
                        }
                    }
                }
                this.LoadData(rs);
                return;
            }
            
            if(chbxThanhPho.isSelected()){                      // Tìm kiếm theo Thành phố
                rsTemp = (ArrayList<DIAOC>)rs.clone();
                rs.clear();
                
                String maThanhPho = ((THANHPHO)cbxThanhPhoTraCuu.getSelectedItem()).getMaThanhPho();
                for(DIAOC d : rsTemp){
                    if (d.getDiaChiDiaOc().getMaThanhPho().equals(maThanhPho)) {
                        rs.add(d);
                    }
                }
                
            }
            
            if (chbxQuan.isSelected()) {                        // Tìm kiếm theo Quận
                rsTemp = (ArrayList<DIAOC>)rs.clone();
                rs.clear();
                String maQuan = ((QUAN)cbxQuanTraCuu.getSelectedItem()).getMaQuan();
                for(DIAOC d : rsTemp){
                    if (d.getDiaChiDiaOc().getMaQuan().equals(maQuan)) {
                        rs.add(d);
                    }
                }
            }
            
            if (chbxPhuong.isSelected()) {                        // Tìm kiếm theo Phường
                rsTemp = (ArrayList<DIAOC>)rs.clone();
                rs.clear();
                String maPhuong = ((PHUONG)cbxPhuongTraCuu.getSelectedItem()).getMaPhuong();
                for(DIAOC d : rsTemp){
                    if (d.getDiaChiDiaOc().getMaPhuong().equals(maPhuong)) {
                        rs.add(d);
                    }
                }
            }
            
            if (chbxDuong.isSelected()) {                       // Tìm kiếm theo Đường                
                rsTemp = (ArrayList<DIAOC>)rs.clone();
                rs.clear();
                String maDuong = ((DUONG)cbxDuongTraCuu.getSelectedItem()).getMaDuong();
                for(DIAOC d : rsTemp){
                    if(d.getDiaChiDiaOc().getMaDuong().equals(maDuong)){
                        rs.add(d);
                    }
                }
            }
            
            if (chbxLoaiDiaOc.isSelected()) {                   // Tìm kiếm theo Loại địa ốc
                rsTemp = (ArrayList<DIAOC>)rs.clone();
                rs.clear();
                String maLoaiDiaOc = ((LOAIDIAOC)cbxLoaiDiaOcTraCuu.getSelectedItem()).getMaLoaiDiaOc();
                for(DIAOC d : rsTemp){
                    if(d.getMaLoaiDiaOc().equals(maLoaiDiaOc)){
                        rs.add(d);
                    }
                }
            }
            
            if (chbxTrangThai.isSelected()) {                   // Tìm kiếm theo Trạng Thái
                rsTemp = (ArrayList<DIAOC>)rs.clone();
                rs.clear();
                String trangThai = cbxTrangThaiTraCuu.getSelectedItem().toString();
                for(DIAOC d : rsTemp){
                    if(d.getTrangThai().trim().equals(trangThai)){
                        rs.add(d);
                    }
                }
            }
            this.LoadData(rs);
        } catch (Exception ex) {
            Logger.getLogger(frmDiaOc.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_btnTimKiemActionPerformed

    private void btnNoiDungQCActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNoiDungQCActionPerformed
        if (tblDiaOc.getSelectedRow() != -1) {
            String MaDiaOc = tblDiaOc.getValueAt(tblDiaOc.getSelectedRow(), 0).toString();
            String MaND = "";
            try {
                MaND = dbDiaOc.GetMaND_From_MaDiaOc(MaDiaOc);
            } catch (Exception ex) {
                JOptionPane.showMessageDialog(rootPane, ex.toString());
                Logger.getLogger(frmDiaOc.class.getName()).log(Level.SEVERE, null, ex);
            }
            if (MaND.equals("")) {
                JOptionPane.showMessageDialog(rootPane, java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("propertynotsign"));
            }else{
                frmNoiDungQC f = new frmNoiDungQC(MaND);
                Utilities.Utilities.setFontForAll(f, new Font("Calibri", 0, 14));
                f.setLocation(155, 0);
                f.setClosable(true);
                f.show();
                this.getParent().add(f,0);
            }
        }else JOptionPane.showMessageDialog(rootPane, java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("mustselectaproperty"));
    }//GEN-LAST:event_btnNoiDungQCActionPerformed

    private void btnPhieuDangKyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPhieuDangKyActionPerformed
        if (tblDiaOc.getSelectedRow() != -1) {
            String MaDiaOc = tblDiaOc.getValueAt(tblDiaOc.getSelectedRow(), 0).toString();
            
            try {
                if (dbPhieuDangKy.IsDiaOcExist(MaDiaOc)) {
                    frmPhieuDangKy frm = new frmPhieuDangKy(MaDiaOc);
                    Utilities.Utilities.setFontForAll(frm, new Font("Calibri", 0, 14));
                    frm.setLocation(155, 0);
                    frm.setClosable(true);
                    frm.show();
                    this.getParent().add(frm,0);
                }else JOptionPane.showMessageDialog(rootPane, java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("propertynotsign"));
            } catch (Exception ex) {
                JOptionPane.showMessageDialog(rootPane, ex.toString());
                Logger.getLogger(frmDiaOc.class.getName()).log(Level.SEVERE, null, ex);
            }
                    
        }else JOptionPane.showMessageDialog(rootPane, java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("mustselectaproperty"));
    }//GEN-LAST:event_btnPhieuDangKyActionPerformed

    // Xử lý xóa hoàn toàn một Địa ốc cùng các bảng liên quan đến nó
    private void btnDeleteAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeleteAllActionPerformed
        btnGiaHan.setEnabled(false);
        btnThongBao.setEnabled(false);
        
        if (tblDiaOc.getSelectedRow() != -1) {
            int i = JOptionPane.showConfirmDialog(this, java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("really delete all"),
                    java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("warn"),JOptionPane.YES_NO_OPTION);
            if (i != 0) {
                return;
            }
            try {
                String MaDiaOc = tblDiaOc.getValueAt(tblDiaOc.getSelectedRow(), 0).toString();
                
                ArrayList<PHIEUDANGKY> phieuDKEntities = dbPhieuDangKy.GetAllPhieuDKByMaDiaOc(MaDiaOc);
                String MaND = dbDiaOc.GetMaND_From_MaDiaOc(MaDiaOc);
                for(PHIEUDANGKY p : phieuDKEntities){
                    String MaPhieuDK = p.getMaPhieuDangKy();
                    RSCall.ToBuomRSc toBuom = new ToBuomRSc();
                    RSCall.QCBangRSc qcBang = new QCBangRSc();
                    RSCall.QCBaoRSc qcBao = new QCBaoRSc();
                    if (toBuom.IsMaPhieuDK_ToBuomExist(MaPhieuDK)) {
                        String MaToBuom = toBuom.GetToBuomByMaPhieuDK(MaPhieuDK).getMaToBuom();
                        toBuom.Delete(MaToBuom);
                    }
                    if (qcBang.IsMaPhieuDK_BangExist(MaPhieuDK)) {
                        String MaQCBang = qcBang.GetQCBangByMaPhieuDK(MaPhieuDK).getMaQCBang();
                        qcBang.Delete(MaQCBang);
                    }
                    if (qcBao.IsMaPhieuDK_BaoExist(MaPhieuDK)) {
                        String MaQCBao = qcBao.GetQCBaoByMaPhieuDK(MaPhieuDK).getMaQCBao();
                        qcBao.Delete(MaQCBao);
                    }
                    dbPhieuDangKy.Delete(MaPhieuDK);
                }
                    
                
                RSCall.NoiDungRSc dbNoiDungQC = new NoiDungRSc();
                RSCall.HinhAnhRSc dbHinhAnh = new HinhAnhRSc();                        
                ArrayList<Entities.HINHANH> listHinhAnh = dbHinhAnh.SelectHinhAnhByMaND(MaND);
                if (!listHinhAnh.isEmpty()) {
                    for(Entities.HINHANH h : listHinhAnh){
                        dbHinhAnh.Delete(h.getMaHinhAnh());
                    }
                }
                dbNoiDungQC.Delete(MaND);
                dbDiaOc.Delete(MaDiaOc);
                this.LoadData(dbDiaOc.GetAllRows());
                JOptionPane.showMessageDialog(rootPane, java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("deletedall") + MaDiaOc);
            } catch (Exception e) {
                JOptionPane.showMessageDialog(rootPane, e.toString());
            }
        }else JOptionPane.showMessageDialog(rootPane, java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("mustselectaproperty"));
    }//GEN-LAST:event_btnDeleteAllActionPerformed

    
    // Xem danh sách các Địa ốc đã hết hạn rao bán
    private void btnHetHanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnHetHanActionPerformed
        try
        {
            Calendar cal = Calendar.getInstance();
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            Date nowTime = Date.valueOf(sdf.format(cal.getTime()));
            
            ArrayList<String> rsMaDiaOc = new ArrayList<String>();
            dbPhieuDangKy = new PhieuDangKyRSc();
            for(PHIEUDANGKY p : dbPhieuDangKy.mainList){
                String trangThai = dbDiaOc.GetRowByID(p.getMaDiaOc()).getTrangThai().trim();
                if(dbPhieuDangKy.GetPhieuDKByMaDiaOc(p.getMaDiaOc()).getDenNgay().compareTo(nowTime) != 1 && trangThai.equals("Chưa bán")){
                    if (!rsMaDiaOc.contains(p.getMaDiaOc())) {
                        rsMaDiaOc.add(p.getMaDiaOc());
                    }  
                }
            }
            
            btnGiaHan.setEnabled(rsMaDiaOc.size() > 0);
            btnThongBao.setEnabled(rsMaDiaOc.size() > 0);
            ArrayList<DIAOC> lst = new ArrayList<DIAOC>();
            for(String maDiaOc : rsMaDiaOc){
                lst.add(dbDiaOc.GetRowByID(maDiaOc));
            }
            this.LoadData(lst);
            
        }
        catch(Exception e)
        {
            JOptionPane.showMessageDialog(this, e.toString());
        }
    }//GEN-LAST:event_btnHetHanActionPerformed

    private void btnGiaHanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGiaHanActionPerformed
        if (tblDiaOc.getSelectedRow() != -1) {
            String MaDiaOc = tblDiaOc.getValueAt(tblDiaOc.getSelectedRow(), 0).toString();
            frmGiaHan frm = new frmGiaHan(MaDiaOc);
            Utilities.Utilities.setFontForAll(frm, new Font("Calibri", 0, 14));
            frm.setLocation(155, 0);
            frm.setClosable(true);
            frm.show();
            this.getParent().add(frm,0);
            
        }else JOptionPane.showMessageDialog(rootPane, java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("mustselectaproperty"));
    }//GEN-LAST:event_btnGiaHanActionPerformed

    private void chbxThanhPhoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chbxThanhPhoActionPerformed
        cbxThanhPhoTraCuu.setEnabled(chbxThanhPho.isSelected());
    }//GEN-LAST:event_chbxThanhPhoActionPerformed

    private void chbxQuanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chbxQuanActionPerformed
        cbxQuanTraCuu.setEnabled(chbxQuan.isSelected());
    }//GEN-LAST:event_chbxQuanActionPerformed

    private void chbxPhuongActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chbxPhuongActionPerformed
        cbxPhuongTraCuu.setEnabled(chbxPhuong.isSelected());
    }//GEN-LAST:event_chbxPhuongActionPerformed

    private void chbxDuongActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chbxDuongActionPerformed
        cbxDuongTraCuu.setEnabled(chbxDuong.isSelected());
    }//GEN-LAST:event_chbxDuongActionPerformed

    private void tbxDienTichDatKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tbxDienTichDatKeyTyped
        Utilities.Utilities.tbxKeyTyped(evt);
    }//GEN-LAST:event_tbxDienTichDatKeyTyped

    private void tbxDienTichXayDungKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tbxDienTichXayDungKeyTyped
        Utilities.Utilities.tbxKeyTyped(evt);
    }//GEN-LAST:event_tbxDienTichXayDungKeyTyped

    private void tbxGiaBanKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tbxGiaBanKeyTyped
        Utilities.Utilities.tbxKeyTyped(evt);
    }//GEN-LAST:event_tbxGiaBanKeyTyped

    private void btnThongBaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnThongBaoActionPerformed
        if (tblDiaOc.getSelectedRow() != -1) {
            try {
                String MaDiaOc = tblDiaOc.getValueAt(tblDiaOc.getSelectedRow(), 0).toString();
                
                PHIEUDANGKY phieuDKEntities = dbPhieuDangKy.GetPhieuDKByMaDiaOc(MaDiaOc);
                KHACHHANG k = dbKhachHang.GetRowByID(phieuDKEntities.getMaKH());
                ArrayList<String> listEmail = new ArrayList<String>();
                listEmail.add(k.getEmail());
                SendMail frm = new SendMail(listEmail);
                Utilities.Utilities.setFontForAll(frm, new Font("Calibri", 0, 14));
                frm.setLocation(155, 0);
                frm.setClosable(true);
                frm.show();
                this.getParent().add(frm,0);
            } catch (Exception e) {
                JOptionPane.showMessageDialog(rootPane, e.toString());
            }
        }else JOptionPane.showMessageDialog(rootPane, java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("mustselectaproperty"));
    }//GEN-LAST:event_btnThongBaoActionPerformed

    private void cbxQuanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbxQuanActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cbxQuanActionPerformed

    private void setColumn() {
        this.tblDiaOc.getColumnModel().getColumn(0).setPreferredWidth(15);
        this.tblDiaOc.getColumnModel().getColumn(1).setPreferredWidth(60);
        this.tblDiaOc.getColumnModel().getColumn(2).setPreferredWidth(180);
        this.tblDiaOc.getColumnModel().getColumn(3).setPreferredWidth(10);
        this.tblDiaOc.getColumnModel().getColumn(4).setPreferredWidth(10);
        this.tblDiaOc.getColumnModel().getColumn(5).setPreferredWidth(10);
        this.tblDiaOc.getColumnModel().getColumn(6).setPreferredWidth(10);
        
        this.tblDiaOc.getColumnModel().getColumn(7).setPreferredWidth(30);
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAdd;
    private javax.swing.JButton btnDanhSach;
    private javax.swing.JButton btnDelete;
    private javax.swing.JButton btnDeleteAll;
    private javax.swing.JButton btnGiaHan;
    private javax.swing.JButton btnHetHan;
    private javax.swing.JButton btnNoiDungQC;
    private javax.swing.JButton btnPhieuDangKy;
    private javax.swing.JButton btnThongBao;
    private javax.swing.JButton btnTimKiem;
    private javax.swing.JButton btnUpdate;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JComboBox cbxDuong;
    private javax.swing.JComboBox cbxDuongTraCuu;
    private javax.swing.JComboBox cbxLoaiDiaOc;
    private javax.swing.JComboBox cbxLoaiDiaOcTraCuu;
    private javax.swing.JComboBox cbxPhuong;
    private javax.swing.JComboBox cbxPhuongTraCuu;
    private javax.swing.JComboBox cbxQuan;
    private javax.swing.JComboBox cbxQuanTraCuu;
    private javax.swing.JComboBox cbxThanhPho;
    private javax.swing.JComboBox cbxThanhPhoTraCuu;
    private javax.swing.JComboBox cbxTrangThai;
    private javax.swing.JComboBox cbxTrangThaiTraCuu;
    private javax.swing.JCheckBox chbxDuong;
    private javax.swing.JCheckBox chbxLoaiDiaOc;
    private javax.swing.JCheckBox chbxMaDiaOc;
    private javax.swing.JCheckBox chbxPhuong;
    private javax.swing.JCheckBox chbxQuan;
    private javax.swing.JCheckBox chbxThanhPho;
    private javax.swing.JCheckBox chbxTrangThai;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JLabel jlabel;
    private javax.swing.JTable tblDiaOc;
    private javax.swing.JTextField tbxDiaChiCTDiaOc;
    private javax.swing.JTextField tbxDienTichDat;
    private javax.swing.JTextField tbxDienTichXayDung;
    private javax.swing.JTextField tbxGiaBan;
    private javax.swing.JTextField tbxHuong;
    private javax.swing.JTextField tbxMaDiaOc_TraCuu;
    private javax.swing.JTextField tbxViTri;
    private javax.swing.JTextArea txtAreaMoTa;
    // End of variables declaration//GEN-END:variables

    private RSCall.KhachHangRSc dbKhachHang;
    private RSCall.DiaOcRSc dbDiaOc;
    private RSCall.PhieuDangKyRSc dbPhieuDangKy;
    private RSCall.LoaiDiaOCRSc dbLoaiDiaOc;
    private RSCall.ThanhPhoRSc dbThanhPho;
    private RSCall.QuanRSc dbQuan;
    private RSCall.PhuongRSc dbPhuong;
    private RSCall.DuongRSc dbDuong;
    
    
    private ArrayList<String> listThanhPho;
    private ArrayList<String> listQuan;
    private ArrayList<String> listPhuong;
    private ArrayList<String> listDuong;
    private ArrayList<String> listLoaiDiaOc;
    
    private void Creation(){
        try {
            dbKhachHang = new KhachHangRSc();
            dbDiaOc = new DiaOcRSc();
            dbPhieuDangKy = new PhieuDangKyRSc();
            dbLoaiDiaOc = new LoaiDiaOCRSc();
            dbThanhPho = new ThanhPhoRSc();
            dbQuan = new QuanRSc();
            dbPhuong = new PhuongRSc();
            dbDuong = new DuongRSc();    
            listThanhPho = new ArrayList<String> ();
            listQuan = new ArrayList<String> ();
            listPhuong = new ArrayList<String> ();
            listDuong = new ArrayList<String> ();
            listLoaiDiaOc = new ArrayList<String>();
            
            // Tạo dữ liệu cho Loại địa ốc
            for(LOAIDIAOC l : dbLoaiDiaOc.mainList){
                cbxLoaiDiaOc.addItem(l);
                cbxLoaiDiaOcTraCuu.addItem(l);
                listLoaiDiaOc.add(l.getMaLoaiDiaOc());
            }
            
            // Tạo dữ liệu cho Thành phố
            for(THANHPHO t : dbThanhPho.mainList){
                cbxThanhPho.addItem(t);
                cbxThanhPhoTraCuu.addItem(t);
                listThanhPho.add(t.getMaThanhPho());
            }
            
            // Tạo dữ liệu cho Quận
            for(QUAN q : dbQuan.mainList){
                cbxQuan.addItem(q);
                cbxQuanTraCuu.addItem(q);
                listQuan.add(q.getMaQuan());
            }
            
            // Tạo dữ liệu cho Phường
            for(PHUONG p : dbPhuong.mainList){
                cbxPhuong.addItem(p);
                cbxPhuongTraCuu.addItem(p);
                listPhuong.add(p.getMaPhuong());
            }
            
            // Tạo dữ liệu cho Đường
            for(DUONG d : dbDuong.mainList){
                cbxDuong.addItem(d);
                cbxDuongTraCuu.addItem(d);
                listDuong.add(d.getMaDuong());
            }
            
            
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(rootPane, ex.toString());
            Logger.getLogger(frmDiaOc.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    private void LoadData(ArrayList<DIAOC> lst){
        try
        {
            DefaultTableModel dtm = new DefaultTableModel(){
                @Override
                public boolean isCellEditable(int x,int y){
                   return false;
                };
            };
            dtm.addColumn(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("id"));
            dtm.addColumn(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("type"));
            dtm.addColumn(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("address"));
            dtm.addColumn(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("dtdat"));
            dtm.addColumn(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("dtxd"));
            dtm.addColumn(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("direction"));
            dtm.addColumn(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("location"));
            dtm.addColumn(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("state"));
            dtm.addColumn(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("describe"));
            dtm.addColumn(java.util.ResourceBundle.getBundle("Presentation/" + frmMain.resource).getString("cost"));

            for(int i=0;i<lst.size();i++)
            {
                DIAOC diaOc = lst.get(i);
                Vector _v = new Vector();
                _v.add(diaOc.getMaDiaOc());
                
                _v.add(dbLoaiDiaOc.GetNameByID(diaOc.getMaLoaiDiaOc()));
                String tenThanhPho = dbThanhPho.GetRowByID(diaOc.getDiaChiDiaOc().getMaThanhPho()).getTenThanhPho().trim();
                String tenQuan = dbQuan.GetRowByID(diaOc.getDiaChiDiaOc().getMaQuan()).getTenQuan().trim();
                String tenPhuong = dbPhuong.GetRowByID(diaOc.getDiaChiDiaOc().getMaPhuong()).getTenPhuong().trim();
                String tenDuong = dbDuong.GetRowByID(diaOc.getDiaChiDiaOc().getMaDuong()).getTenDuong().trim();
                String diaChiCT = diaOc.getDiaChiDiaOc().getDiaChiCT().trim();
                String diaChi = diaChiCT + " " + tenDuong + " " + tenPhuong + " " + tenQuan + " " + tenThanhPho;
                _v.add(diaChi);
                _v.add(diaOc.getDienTichDat());
                _v.add(diaOc.getDienTichXayDung());
                _v.add(diaOc.getHuong().trim());
                _v.add(diaOc.getViTri().trim());
                _v.add(diaOc.getTrangThai());
                _v.add(diaOc.getMoTa().trim().trim());
                _v.add(diaOc.getGiaBan());
                dtm.addRow(_v);
            }
            this.tblDiaOc.setModel(dtm);
            setColumn();
        }
        catch(Exception e)
        {
            JOptionPane.showMessageDialog(this, e.toString());
        }
    }
}

